package system

import (
	"github.com/gogf/gf/v2/frame/g"
	"github.com/gogf/gf/v2/net/ghttp"
	"github.com/sagoo-cloud/sagooiot/api/v1/common"
)

// GetApplicationListReq 获取数据列表
type GetApplicationListReq struct {
	g.Meta `path:"/application/list" method:"get" summary:"获取应用管理列表" tags:"应用管理"`
	common.PaginationReq
}
type GetApplicationListRes struct {
	Data []GetApplicationByIdRes
	common.PaginationRes
}

// GetApplicationByIdReq 获取指定ID的数据
type GetApplicationByIdReq struct {
	g.Meta `path:"/application/get" method:"get" summary:"获取应用管理" tags:"应用管理"`
	Id     int `json:"id"        description:"id" v:"required#id不能为空"`
}
type GetApplicationByIdRes struct {
	Desc      string `json:"desc"          description:"应用说明"`
	Status    int    `json:"status"          description:"应用状态：0未启用，1启用" `
	CreatedAt string `json:"createdAt"          description:""`
	Name      string `json:"name"          description:"应用名称"`
	OrgId     int    `json:"orgId"          description:"SagooIOT中的组织"`
	AppType   string `json:"appType"          description:"应用类型"`
	Icon      string `json:"icon"          description:"应用图标"`
	SecureKey string `json:"secureKey"          description:"sk"`
	RoleId    int    `json:"roleId"          description:"SagooIOT中的角色"`
	UpdatedAt string `json:"updatedAt"          description:""`
	DeletedAt string `json:"deletedAt"          description:""`
	Id        int    `json:"id"          description:""`
	AccessKey string `json:"accessKey"          description:"ak"`
	AppId     string `json:"appId"          description:"应用标识"`
}

// AddApplicationReq 添加数据
type AddApplicationReq struct {
	g.Meta    `path:"/application/add" method:"post" summary:"添加应用管理" tags:"应用管理"`
	AccessKey string `json:"accessKey"          description:"ak"`
	Name      string `json:"name"          description:"应用名称" v:"required#名称不能为空"`
	Desc      string `json:"desc"          description:"应用说明"`
	Status    int    `json:"status"          description:"应用状态：0未启用，1启用" v:"required#应用状态不能为空"`
	AppType   string `json:"appType"          description:"应用类型"`
	OrgId     string `json:"orgId"          description:"SagooIOT中的组织" v:"required#组织不能为空"`
	Icon      string `json:"icon"          description:"应用图标"  v:"required#应用图标不能为空"`
	SecureKey string `json:"secureKey"          description:"sk" `
	RoleId    string `json:"roleId"          description:"SagooIOT中的角色" v:"required#角色不能为空"`
}
type AddApplicationRes struct{}

type SetApplicationStatusRes struct {
}
type SetApplicationStatusReq struct {
	g.Meta `path:"/application/status" method:"put" summary:"启动/禁用 应用管理" tags:"应用管理"`
	Id     int `json:"id"          description:""  v:"required#id不能为空"`
	Status int `json:"status"          description:"应用状态：0未启用，1启用" v:"required#应用状态不能为空"`
}

// EditApplicationReq 编辑数据api
type EditApplicationReq struct {
	g.Meta    `path:"/application/edit" method:"put" summary:"编辑应用管理" tags:"应用管理"`
	Name      string `json:"name"          description:"应用名称" v:"required#名称不能为空"`
	Desc      string `json:"desc"          description:"应用说明"`
	Status    int    `json:"status"          description:"应用状态：0未启用，1启用"  v:"required#应用状态不能为空"`
	AppType   string `json:"appType"          description:"应用类型"`
	OrgId     int    `json:"orgId"          description:"SagooIOT中的组织"  v:"required#组织不能为空"`
	Id        int    `json:"id"          description:""  v:"required#id不能为空"`
	Icon      string `json:"icon"          description:"应用图标"  v:"required#应用图标不能为空"`
	SecureKey string `json:"secureKey"          description:"sk"`
	RoleId    int    `json:"roleId"          description:"SagooIOT中的角色"  v:"required#角色不能为空"`
	AccessKey string `json:"accessKey"          description:"ak"`
}
type EditApplicationRes struct{}

// DeleteApplicationReq 删除数据
type DeleteApplicationReq struct {
	g.Meta `path:"/application/delete" method:"delete" summary:"删除应用管理" tags:"应用管理"`
	Ids    []int `json:"ids"        description:"ids" v:"required#ids不能为空"`
}
type DeleteApplicationRes struct{}

type RestartApplicationListReq struct {
	g.Meta `path:"/application/restart" method:"get" summary:"重启应用" tags:"应用管理"`
}
type RestartApplicationListRes struct {
}

// UploadReq .
type UploadReq struct {
	g.Meta `path:"/application/upload" tags:"应用管理" method:"POST" summary:"应用管理"`
	File   *ghttp.UploadFile `json:"file" type:"file" dc:"选择上传文件"`
}

type UploadRes struct {
	Url string `json:"url"`
}

type VersionInfoReq struct {
	g.Meta `path:"/application/info" method:"get" summary:"版本信息" tags:"应用管理"`
}

type VersionInfoRes struct {
	Version     string `json:"version" description:"版本"`
	BuildTime   string `json:"buildTime" description:"升级时间"`
	VersionDesc string `json:"versionDesc" description:"版本说明"`
}
